package com.atguigu.crowd.handler;

import com.atguigu.crowd.entity.po.MemberPO;
import com.atguigu.crowd.service.MemberService;
import com.atguigu.crowd.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MemberProviderHandler {

    @Autowired
    private MemberService memberService;

    @RequestMapping("get/memberpo/by/login/acct/remote")
    ResultEntity<MemberPO> getMemberPOByLoginAcctRemote(@RequestParam("loginAcct") String loginAcct) {
        MemberPO memberPO = null;
        try {
            // 调用本地service完成查询
            memberPO = memberService.getMemberPOByLoginAcct(loginAcct);
            // 如果没有抛异常，就返回成功结果
            return ResultEntity.successWithData(memberPO);
        } catch (Exception e) {
            // 如果捕获异常，就返回失败结果
            return ResultEntity.failed(e.getMessage());
        }
    }
}
